#include "stdafx.h"
#include "CppUnitTest.h"

#include "ProcParamsDefs.h"
#include "ProcParamDef.h"
#include "ProcParamDefInt.h"
#include "ProcParamDefDouble.h"
#include "ProcParamDefString.h"

#include "ProcParamInt.h"
#include "ProcParamDouble.h"
#include "ProcParamString.h"

#include "ProcParamsInputs.h"
#include "ProcParamsOutputs.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace PluginICProcStepsTest
{
	TEST_CLASS(ProcParamDefTest)
	{
	private:
		ProcParamsDefs *_Params;
		ProcParamDefInt *_DefInt;
		ProcParamDefDouble *_DefDouble;
		ProcParamDefString *_DefString;

	public:
		TEST_METHOD_INITIALIZE(InitProcParamDefTest)
		{
			_Params = new ProcParamsDefs();
			_DefInt =  new 	ProcParamDefInt();
			_DefDouble = new ProcParamDefDouble();
			_DefString = new ProcParamDefString();

			_Params->ClearParams();
		}

		TEST_METHOD_CLEANUP(DeinitProcParamDefTest)
		{
			if (_Params != '\0')
				delete _Params;
			if (_DefInt != '\0')
				delete _DefInt;
			if (_DefDouble != '\0')
				delete _DefDouble;
			if (_DefString != '\0')
				delete _DefString;
		}
		
		TEST_METHOD(CreateProcParamDefTest)
		{
			Assert::IsNotNull (_DefInt);
			Assert::IsFalse (_DefInt->IsValid());
			Assert::IsNotNull (_DefDouble);
			Assert::IsFalse (_DefDouble->IsValid());
			Assert::IsNotNull (_DefString);
			Assert::IsFalse (_DefString->IsValid());
		}

		TEST_METHOD(CreateProcParamsDefTest)
		{
			Assert::IsNotNull (_Params);
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
			Assert::IsFalse(_Params->IsValid());
			Assert::IsFalse( _Params->Validate());		//no IPluginICProcStepsParamAttribOutputNameResult
			Assert::IsFalse( _Params->IsValid());
		}

		TEST_METHOD(CreateParamDefDoubleTest)
		{
			Assert::IsTrue(_Params->AddParamDef(new ProcParamDefDouble(0, IPluginICProcStepsParamAttribOutputNameResult, "ok=0.1", IPluginICProcStepsParamDef::output, 0.1, 10.0)));

			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefDouble()));																		//no params
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefDouble(0, '\0', "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));						//bad name
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefDouble(1, "oneI", '\0', IPluginICProcStepsParamDef::input, 0.1, 10.0)));						//bad description
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefDouble(0, '\0', "zero", IPluginICProcStepsParamDef::output, 0.1, 10.0)));						//bad name
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefDouble(1, "oneI", '\0', IPluginICProcStepsParamDef::output, 0.1, 10.0)));						//bad description

			Assert::IsTrue( _Params->Validate());	
			Assert::IsTrue(  _Params->IsValid());
			Assert::AreEqual (  0,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
	
			Assert::AreEqual (  1,  _Params->GetParamDefCount());
			Assert::IsTrue(  _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->IsValid());
			Assert::IsTrue(  IPluginICProcStepsParamDef::doubleP == _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->GetTypeP());
			Assert::IsTrue( IPluginICProcStepsParamDefDoubleP == _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->GetTypeStr());
			Assert::AreEqual (  0.1,  dynamic_cast<ProcParamDefDouble *>(_Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult))->GetMinValue());
			Assert::AreEqual (  10.0,  dynamic_cast<ProcParamDefDouble *>(_Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult))->GetMaxValue());

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse(_Params->IsValid());
			Assert::AreEqual (  ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(CreateParamDefIntTest)
		{
			Assert::IsTrue(_Params->AddParamDef(new ProcParamDefInt(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 1, 10)));

			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefInt()));																	//no params
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefInt(0, '\0', "zero", IPluginICProcStepsParamDef::input, 1, 10)));						//bad name
			Assert::IsFalse(_Params->AddParamDef(new ProcParamDefInt(1, "oneI", '\0', IPluginICProcStepsParamDef::input, 1, 10)));						//bad description
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefInt(0, '\0', "zero", IPluginICProcStepsParamDef::output, 1, 10)));						//bad name
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefInt(1, "oneI", '\0', IPluginICProcStepsParamDef::output, 1, 10)));						//bad description

			Assert::IsTrue(  _Params->Validate());	
			Assert::IsTrue( _Params->IsValid());
			Assert::AreEqual (0,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::AreEqual (1,  _Params->GetParamDefCount());
			Assert::IsTrue( _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->IsValid());
			Assert::IsTrue( IPluginICProcStepsParamDef::intP == _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->GetTypeP());
			Assert::IsTrue( IPluginICProcStepsParamDefIntP == _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->GetTypeStr());
			Assert::AreEqual ( 1,  dynamic_cast<ProcParamDefInt *>(_Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult))->GetMinValue());
			Assert::AreEqual (10,  dynamic_cast<ProcParamDefInt *>(_Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult))->GetMaxValue());

			Assert::IsTrue( _Params->Validate());		
			Assert::IsTrue( _Params->IsValid());

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());

		}

		TEST_METHOD(CreateParamDefStringTest)
		{
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 1, 10)));

			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString()));																			//no params
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString(0, '\0', "zero",     IPluginICProcStepsParamDef::input, 1, 10)));							//bad name
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString(1, "oneI", '\0',     IPluginICProcStepsParamDef::input, 1, 10)));							//bad description
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString(2, "twoI", "two",    IPluginICProcStepsParamDef::input, IPluginICProcStepsParamDefString::MinLen-1, 10)));	//too short
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString(3, "threeI", "three", IPluginICProcStepsParamDef::input, 1, IPluginICProcStepsParamDefString::MaxLen+1)));	//too long

			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString(0, '\0', "zero",     IPluginICProcStepsParamDef::output, 1, 10)));								//bad name
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString(1, "oneI", '\0',     IPluginICProcStepsParamDef::output, 1, 10)));								//bad description
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString(2, "twoI", "two",    IPluginICProcStepsParamDef::output, IPluginICProcStepsParamDefString::MinLen-1, 10)));	//too short
			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefString(3, "threeI", "three", IPluginICProcStepsParamDef::output, 1, IPluginICProcStepsParamDefString::MaxLen+1)));	//too long

			Assert::IsTrue( _Params->Validate());	
			Assert::IsTrue( _Params->IsValid());
			Assert::AreEqual ( 0,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::AreEqual ( 1,  _Params->GetParamDefCount());
			Assert::IsTrue( _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->IsValid());
			Assert::IsTrue( IPluginICProcStepsParamDef::stringP == _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->GetTypeP());
			Assert::IsTrue( IPluginICProcStepsParamDefStringP == _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->GetTypeStr());
			Assert::AreEqual ( 1,  dynamic_cast<ProcParamDefString *>(_Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult))->GetMinLength());
			Assert::AreEqual ( 10,  dynamic_cast<ProcParamDefString *>(_Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult))->GetMaxLength());

			Assert::IsTrue( _Params->Validate());		
			Assert::IsTrue(  _Params->IsValid());

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}


		TEST_METHOD(ParamDefAddParamDefMinTest)
		{
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 1, 10)));

			Assert::IsFalse( _Params->IsValid());
			Assert::IsTrue( _Params->Validate());		//IPluginICProcStepsParamAttribOutputNameResult
			Assert::IsTrue( _Params->IsValid());

			Assert::AreEqual ( 1,  _Params->GetParamDefCount());

			Assert::IsTrue( _Params->ClearParams());
			Assert::AreEqual (ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
			Assert::IsFalse( _Params->IsValid());
		}

		TEST_METHOD(ParamDefAddParamDefTypicalTest)
		{
			Assert::AreEqual (ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroO", "zero", IPluginICProcStepsParamDef::output, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneO", "one", IPluginICProcStepsParamDef::output, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, IPluginICProcStepsParamAttribOutputNameResult, "two", IPluginICProcStepsParamDef::output, 1, 10)));
		
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneI", "one", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, "twoI", "two", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::AreEqual ( ProcParamsDefs::InvalidCount, _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::IsTrue(  _Params->Validate());
			Assert::IsTrue(  _Params->IsValid());

			Assert::AreEqual ( 6,  _Params->GetParamDefCount());
			Assert::AreEqual ( 3,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::AreEqual ( 3,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));

			Assert::AreEqual (0, _Params->GetParamDefByPosition(0)->GetIndex());
			Assert::AreEqual (1, _Params->GetParamDefByPosition(1)->GetIndex());
			Assert::AreEqual (2, _Params->GetParamDefByPosition(2)->GetIndex());
			Assert::AreEqual (0, _Params->GetParamDefByPosition(3)->GetIndex());
			Assert::AreEqual (1, _Params->GetParamDefByPosition(4)->GetIndex());
			Assert::AreEqual (2, _Params->GetParamDefByPosition(5)->GetIndex());
			Assert::IsNull(_Params->GetParamDefByPosition(6));
			Assert::IsNull(_Params->GetParamDefByPosition(-1));
		
			Assert::IsTrue(_Params->ClearParams());
			Assert::IsFalse( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefAddParamDefNoSeqIndexTest)
		{
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 1, 10)));

			Assert::IsTrue(_Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue(_Params->AddParamDef(new ProcParamDefInt(1, "oneI", "one", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue(_Params->AddParamDef(new ProcParamDefString(3, "threeI", "three", IPluginICProcStepsParamDef::input, 1, 10)));		//missing 2
	
			Assert::IsFalse( _Params->Validate());		//input index: 0,1,3 
			Assert::IsFalse( _Params->IsValid());

			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, "twoI", "two", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue(  _Params->Validate());		//input index: 0,1,2,3 
			Assert::IsTrue(  _Params->IsValid());

			Assert::AreEqual (4,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::AreEqual (5,  _Params->GetParamDefCount());

			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, "two", "two", IPluginICProcStepsParamDef::output, 1, 10)));
			Assert::IsFalse( _Params->Validate());		//output index: 0,2
			Assert::IsFalse( _Params->IsValid());

			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(1, "one", "one", IPluginICProcStepsParamDef::output, 1, 10)));
			Assert::IsTrue(  _Params->Validate());		//output index: 0,1,2
			Assert::IsTrue(  _Params->IsValid());

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse( _Params->IsValid());
			Assert::AreEqual (ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefAddParamDefDuplicatesTest)
		{
			Assert::IsTrue(_Params->AddParamDef(new ProcParamDefString(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 1, 10)));

			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(0, "oneI", "one", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue(  _Params->Validate());		
			Assert::IsTrue(  _Params->IsValid());
			Assert::AreEqual ( 2,  _Params->GetParamDefCount());

			Assert::IsFalse( _Params->AddParamDef(new ProcParamDefInt(1, "oneI", "one", IPluginICProcStepsParamDef::input, 1, 10)));		//duplicate name
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::IsFalse(_Params->AddParamDef(new ProcParamDefInt(0, "oneII", "one", IPluginICProcStepsParamDef::input, 1, 10)));		//duplicate index
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneII", "one", IPluginICProcStepsParamDef::input, 1, 10)));		//ok
			Assert::IsTrue(  _Params->Validate());	
			Assert::AreEqual ( 2,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneIII", "one", IPluginICProcStepsParamDef::output, 1, 10)));	//duplicate index, but output
			Assert::IsTrue(  _Params->Validate());	
			Assert::AreEqual ( 2,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefGetIndexTest)
		{
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroO", "zero", IPluginICProcStepsParamDef::output, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneO", "one", IPluginICProcStepsParamDef::output, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, IPluginICProcStepsParamAttribOutputNameResult, "two", IPluginICProcStepsParamDef::output, 1, 10)));

			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneI", "one", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, "twoI", "two", IPluginICProcStepsParamDef::input, 1, 10)));

			Assert::AreEqual (ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::IsTrue( _Params->Validate());		
			Assert::IsTrue( _Params->IsValid());

			Assert::AreEqual ( 3,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::AreEqual ( 3,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
														//test
			Assert::AreEqual ( 0, _Params->GetIndex("zeroI"));
			Assert::AreEqual ( 1, _Params->GetIndex("oneI"));
			Assert::AreEqual ( 2, _Params->GetIndex("twoI"));
			Assert::AreEqual ( 0, _Params->GetIndex("zeroO"));
			Assert::AreEqual ( 1, _Params->GetIndex("oneO"));
			Assert::AreEqual ( 2, _Params->GetIndex(IPluginICProcStepsParamAttribOutputNameResult));

			Assert::AreEqual (IPluginICProcStepsParamDef::NotFound, _Params->GetIndex("badname"));
			Assert::AreEqual ( IPluginICProcStepsParamDef::NotFound, _Params->GetIndex('\0'));

			Assert::IsTrue( _Params->Validate());		
			Assert::IsTrue(  _Params->IsValid());

			Assert::IsTrue(_Params->ClearParams());
			Assert::IsFalse( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefGetParamDefTest)
		{
			Assert::AreEqual (  ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneI", "one", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, "twoI", "two", IPluginICProcStepsParamDef::input, 1, 10)));

			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroO", "zero", IPluginICProcStepsParamDef::output, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneO", "one", IPluginICProcStepsParamDef::output, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, IPluginICProcStepsParamAttribOutputNameResult, "two", IPluginICProcStepsParamDef::output, 1, 10)));
			Assert::AreEqual (  ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));

			Assert::IsTrue( _Params->Validate());		
			Assert::IsTrue(  _Params->IsValid());
			Assert::AreEqual (  3,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::AreEqual (  3,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
														//test
			Assert::AreEqual( "zeroI", _Params->GetParamDef("zeroI")->GetName());
			Assert::AreEqual( "oneI", _Params->GetParamDef("oneI")->GetName());
			Assert::AreEqual( "twoI", _Params->GetParamDef("twoI")->GetName());
			Assert::AreEqual( "zeroO", _Params->GetParamDef("zeroO")->GetName());
			Assert::AreEqual( "oneO", _Params->GetParamDef("oneO")->GetName());
			Assert::AreEqual (  IPluginICProcStepsParamAttribOutputNameResult, _Params->GetParamDef(IPluginICProcStepsParamAttribOutputNameResult)->GetName());

			Assert::AreEqual( "zeroI", _Params->GetParamDef(0, IPluginICProcStepsParamDef::input)->GetName());
			Assert::AreEqual( "oneI", _Params->GetParamDef(1, IPluginICProcStepsParamDef::input)->GetName());
			Assert::AreEqual( "twoI", _Params->GetParamDef(2, IPluginICProcStepsParamDef::input)->GetName());
			Assert::AreEqual( "zeroO", _Params->GetParamDef(0, IPluginICProcStepsParamDef::output)->GetName());
			Assert::AreEqual( "oneO", _Params->GetParamDef(1, IPluginICProcStepsParamDef::output)->GetName());
			Assert::AreEqual ( IPluginICProcStepsParamAttribOutputNameResult, _Params->GetParamDef(2, IPluginICProcStepsParamDef::output)->GetName());

			Assert::IsNull( _Params->GetParamDef('\0'));

			Assert::IsTrue(  _Params->Validate());		
			Assert::IsTrue( _Params->IsValid());

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse (  _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefIsMatchTest)
		{
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::IsTrue(_Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneI", "one", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, "twoI", "two", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroO", "zero", IPluginICProcStepsParamDef::output, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(1, "oneO", "one", IPluginICProcStepsParamDef::output, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(2, IPluginICProcStepsParamAttribOutputNameResult, "two", IPluginICProcStepsParamDef::output, 0, 10)));
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));

			Assert::IsTrue( _Params->Validate());	
			Assert::AreEqual ( 3,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::AreEqual ( 3,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsFalse (  _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( inputs.AddParam(new ProcParamDouble(0, "zeroI", IPluginICProcStepsParam::input, 1.0)));
			Assert::IsFalse ( inputs.IsValid());
			Assert::IsTrue(  inputs.Validate());
			Assert::IsTrue(  inputs.IsValid());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( inputs.AddParam(new ProcParamInt(1, "oneI", IPluginICProcStepsParam::input, 2)));
			Assert::IsTrue( inputs.Validate());
			Assert::IsFalse (  _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( inputs.AddParam(new ProcParamString(2, "twoI", IPluginICProcStepsParam::input, "hello")));
			Assert::IsTrue(  inputs.Validate());
			Assert::IsFalse (  _Params->IsMatch(&outputs, &inputs));

		
			Assert::IsTrue( outputs.AddParam(new ProcParamDouble(0, "zeroO", IPluginICProcStepsParam::output, 1.1)));
			Assert::IsTrue(  outputs.AddParam(new ProcParamInt(1, "oneO", IPluginICProcStepsParam::output, 2)));
			Assert::IsTrue(  outputs.AddParam(new ProcParamString(2, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::output, "")));

			Assert::IsTrue( outputs.Validate());	
			Assert::IsTrue( _Params->IsMatch(&outputs, &inputs));			//success

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse ( _Params->IsValid());
			Assert::AreEqual (ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefIsMisMatchNameTest)
		{
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 0, 10)));
			Assert::IsTrue( _Params->Validate());	
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsTrue(  inputs.AddParam(new ProcParamDouble(0, "zero???", IPluginICProcStepsParam::input, 1.0)));
			Assert::IsTrue( inputs.Validate());	
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( outputs.AddParam(new ProcParamString(0, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::input, "")));
			Assert::IsTrue(  outputs.Validate());	
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse ( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());

		}

		TEST_METHOD(ParamDefIsMisMatchTypeTest)
		{
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 0, 10)));
			Assert::IsTrue(  _Params->Validate());	
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
	
													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsTrue(  inputs.AddParam(new ProcParamDouble(0, "zeroI", IPluginICProcStepsParam::input, 1.0)));
			Assert::IsTrue(  inputs.Validate());
			Assert::IsFalse (_Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue(  outputs.AddParam(new ProcParamInt(0, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::output,  1)));	//output:0 is String not Int
			Assert::IsTrue(  outputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse ( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefIsMisMatchDoubleMinValTest)
		{
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 0.1, 10.0)));
			Assert::IsTrue(  _Params->Validate());
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsTrue( inputs.AddParam(new ProcParamDouble(0, "zeroI", IPluginICProcStepsParam::input, 0.0)));		//0.0 < 0.1
			Assert::IsTrue(  inputs.Validate());
			Assert::IsFalse (_Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( outputs.AddParam(new ProcParamDouble(0, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::output, 1.0)));
			Assert::IsTrue(  outputs.Validate());
			Assert::IsFalse (_Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue(_Params->ClearParams());
			Assert::IsFalse (  _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefIsMisMatchDoubleMaxValTest)
		{
			Assert::AreEqual (  ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 0.1, 10.0)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefDouble(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 0.1, 10.0)));
			Assert::IsTrue(  _Params->Validate());
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::AreEqual (  1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

			Assert::IsTrue(  _Params->Validate());	
													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsTrue( inputs.AddParam(new ProcParamDouble(0, "zeroI", IPluginICProcStepsParam::input, 1.0)));
			Assert::IsTrue(  inputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( outputs.AddParam(new ProcParamDouble(0, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::output, 11.0)));	//11.0 > 10.0
			Assert::IsTrue(  outputs.Validate());
			Assert::IsFalse (_Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse ( _Params->IsValid());
			Assert::AreEqual (  ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefIsMisMatchIntMinValTest)
		{
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 0, 10)));
			Assert::IsTrue(  _Params->Validate());
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));	
													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsTrue( inputs.AddParam(new ProcParamInt(0, "zeroI", IPluginICProcStepsParam::input, 1)));
			Assert::IsTrue( inputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( outputs.AddParam(new ProcParamInt(0, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::output,  -1)));
			Assert::IsTrue(  outputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse ( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefIsMisMatchIntMaxValTest)
		{
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefInt(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 1, 10)));
			Assert::IsTrue(  _Params->Validate());
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::AreEqual (1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));

													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsTrue( inputs.AddParam(new ProcParamInt(0, "zeroI", IPluginICProcStepsParam::input, 11)));									//11 > 10
			Assert::IsTrue( inputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( outputs.AddParam(new ProcParamInt(0, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::output, 10)));	
			Assert::IsTrue( outputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse ( _Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefIsMisMatchStringMinLengthTest)
		{
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue( _Params->AddParamDef(new ProcParamDefString(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 0, 10)));
			Assert::IsTrue(  _Params->Validate());
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));	
													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsTrue(inputs.AddParam(new ProcParamString(0, "zeroI", IPluginICProcStepsParam::input, "")));		//strlen("") < 1
			Assert::IsTrue( inputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));
			Assert::IsTrue( outputs.AddParam(new ProcParamString(0, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::output, "")));
			Assert::IsTrue(  outputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue( _Params->ClearParams());
			Assert::IsFalse (_Params->IsValid());
			Assert::AreEqual ( ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

		TEST_METHOD(ParamDefIsMisMatchStringMaxLengthTest)
		{
			Assert::IsTrue(  _Params->AddParamDef(new ProcParamDefString(0, "zeroI", "zero", IPluginICProcStepsParamDef::input, 1, 10)));
			Assert::IsTrue(   _Params->AddParamDef(new ProcParamDefString(0, IPluginICProcStepsParamAttribOutputNameResult, "zero", IPluginICProcStepsParamDef::output, 0, 10)));
			Assert::IsTrue(    _Params->Validate());
			Assert::AreEqual ( 1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::output));
			Assert::AreEqual (1,  _Params->GetParamDefCount(IPluginICProcStepsParamDef::input));
													//test
			ProcParamsInputs inputs;
			ProcParamsOutputs outputs;

			Assert::IsTrue(   inputs.AddParam(new ProcParamString(0, "zeroI", IPluginICProcStepsParam::input, "01234567891")));
			Assert::IsTrue(    inputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue(   outputs.AddParam(new ProcParamString(0, IPluginICProcStepsParamAttribOutputNameResult, IPluginICProcStepsParam::output, "01234567891")));
			Assert::IsTrue(    outputs.Validate());
			Assert::IsFalse ( _Params->IsMatch(&outputs, &inputs));

			Assert::IsTrue(   _Params->ClearParams());
			Assert::IsFalse ( _Params->IsValid());
			Assert::AreEqual (ProcParamsDefs::InvalidCount,  _Params->GetParamDefCount());
		}

	};

}